<% if flash[:notice]  -%>
  <div class="sysmsg"><%= flash[:notice] -%></div>
  <% flash[:notice] = nil -%>
<% end -%>
<table id="columns">
  <tr>
    <!-- Main Messages -->
    <td id="main">
      <div id="info">
        <div id="avatar">
          <%= link_to(image_tag(@user.avatar, :alt => @user.display_name).to_s, {:controller => :message, :action => "user", :id => @user.id} ) -%>
        </div>
        <div id="panel">
          <h1><%= @user.display_name -%></h1>
          <p class="actions">
            <% unless @is_myself -%>
              <% unless @is_existing_friend -%>
                <% session[:ori_uri] = request.request_uri -%>
                <%= link_to("Add friend", :controller => :friend, :action => "add", :id => @user.id) -%>
              <% else -%>
                <span><%= @user.display_name -%> is your friend.</span>
                <% session[:ori_uri] = request.request_uri -%>
                <%= link_to("Delete friend", :controller => :friend, :action => "delete", :id => @user.id) -%>
              <% end -%>
              <%= link_to("Direct Message", :controller => :direct_message, :action => "to", :id => @user.id) -%>
            <% end -%>
          </p>
        </div>
      </div>
      <div id="content">
        <div id="stream" class="message">
          <ol class="wa">
            <% @messages.each do |message| -%>
                  <%
                    #skip the privacy part.
                  -%>
              <li class="unlight">
                <%= link_to(image_tag(@user.avatar, :alt => @user.display_name).to_s, {:controller => :message, :action => :user, :id => @user.id}, :class => "avatar", :title => @user.display_name) -%>
                <%= link_to(@user.display_name, {:controller => :message, :action => :user, :id => @user.id}, :title => @user.display_name) -%>
                <span class="content"><%= message.content -%></span>
                <span class="stamp"><%= link_to("Posted about " + time_string(Time.now.to_i - message.post_at.to_i) + " ago", {:controller => :message, :action => "show", :id => message.id}, :class => "time") -%></span>
                <span class="op">
                  <% if session[:user_name] != nil and session[:user_name] != @user.name-%>
                    <%= link_to("Add to favorite", {:controller => :favorite, :action => "add", :id => message.id}, :class => "post_act share") -%>
                  <% end -%>
                  <% if session[:user_name] == @user.name  -%>
                      <% session[:ori_uri] = request.request_uri -%>
                      <%= link_to("Delete", {:controller => :message, :action => "delete", :id => message.id}, :class => "delete", :confirm => "Do you really want to delete this message?") -%>
                  <% end -%>
                </span>
              </li>
            <% end -%>
          </ol>
        </div>
        <% if @paged -%>
          <ul class="paginator">
            <% if @page > 1 -%>
              <li><%= link_to("&lt;&lt; Previous", :controller => :message, :action => "user", :id => @user.id, :page => (@page - 1)) -%></li>
            <% end -%>
            <% if @page < @page_count or not @page.nil? -%>
              <li><%= link_to("Next &gt;&gt;", :controller => :message, :action => "user", :id => @user.id, :page => (@page + 1)) -%></li>
            <% end -%>
          </ul>
        <% end -%>
      </div>
    </td>
    
    <!-- Sidebar -->
    <!-- All the following values will be replaced by varibles -->
    <td id="sidebar">
      <% unless session[:user_name] -%>
        <% form_tag({:controller => :login, :action => :index},
            :method => :post) do -%>
          <p>
            <label for="name" class="label_input">Name: </label>
            <%= text_field_tag :name, params[:name], :size => 32 -%>
          </p>
          <p>
            <label for="user_password" class="label_input">Password: </label>
            <%= password_field_tag :password, params[:password], :size => 32-%>
          </p>
          <p class="act">
            <%= submit_tag "Login", :class => "formbutton" -%>
          </p>
        <% end -%>
      <% end -%>
      <div id="user_infos">
        <ul class="vcard">
          <!-- All replaced by dynamic information-->
          <%= "<li>Sex: "+ h(@user.sex) + "</li>" if @user.sex.to_s.strip != "" -%>
          <%= "<li>City: <a href=\"@user.website\">"+ h(@user.website) + "</a></li>" if @user.website.to_s.strip != "" -%>
          <%= "<li>City: "+ h(@user.location) + "</li>" if @user.location.to_s.strip != "" -%>
          <%= "<li>Hometown: "+ h(@user.hometown) + "</li>" if @user.hometown.to_s.strip != "" -%>
          <%= "<li id=\"bio\">Description: " + h(@user.description) + "</li>" if @user.description.to_s.strip != "" -%>
        </ul>
      </div>
      <ul id="user_stats">
        <li>
          <a href="/friend/user/<%= @user.id -%>">
            <span class="count"><%= Follower.friend_count(@user.id) -%></span>
            <span class="label">Friends</span>
          </a>
        </li>
        <li>
          <a href="/friend/user/<%= @user.id -%>?opt=f">
            <span class="count"><%= Follower.follower_count(@user.id) -%></span>
            <span class="label">Followers</span>
          </a>
        </li>
        <li>
          <a href="/message/<%= @user.id -%>">
            <span class="count"><%= Message.message_count(@user.id) -%></span>
            <span class="label">Messages</span>
          </a>
        </li>
      </ul>
      <div class="stabs">
        <ul>
          <li class="Current">
            <a href="/home">
              <span class="label">Home</span>
            </a>
          </li>
          <li>
            <a href="/favorite/user/<%= @user.id -%>">
              <span class="label">Favorites</span>
            </a>
          </li>
        </ul>
      </div>
    </td>
  </tr>
</table>